package terra.network.packet.client;

import org.jboss.netty.buffer.ChannelBuffer;

import terra.network.packet.Packet;


public class RequestDropItem extends Packet {

	public int playerId;
	public int oId;
	public int id;
	public int x,y;
	public int count;
	
	public RequestDropItem(int playerId, int oId,int id,int x1,int y1,int c) {
		this.playerId = playerId;
		this.oId = oId;
		this.id = id;
		x=x1;
		y=y1;
		count = c;
	}

	public RequestDropItem() {
	}

	@Override
	public ChannelBuffer toBuffer() {
		ChannelBuffer buf = getNewBuffer();
		buf.writeByte(getId());
		buf.writeInt(playerId);
		buf.writeInt(oId);
		buf.writeInt(id);
		buf.writeInt(x);
		buf.writeInt(y);
		buf.writeInt(count);
		return buf;
	}

	@Override
	public Packet fromBuffer(ChannelBuffer buf) {
		playerId = buf.readInt();
		oId = buf.readInt();
		id = buf.readInt();
		x = buf.readInt();
		y = buf.readInt();
		count = buf.readInt();
		return this;
	}

	@Override
	public int getLength() {
		return 25;
	}

	@Override
	public boolean isDynamicLength() {
		return false;
	}

	@Override
	public byte getId() {
		return 19;
	}

	@Override
	public byte getPriority() {
		return PRIOR_NORMAL;
	}

	public String toString() {
		return "RequestDropItem: "+ playerId+ "_"+oId+"_"+id+" xy: "+ x+"_"+y+" cnt: "+ count;
	}
}
